
/*
    Revolution Engine
    Copyright (C) 2009 Felipe Apablaza

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/


/**
 *
 *  File: Base.hpp
 *  Desc: Base definitions shared among all 
 *        mathematical classes.  
 *
 */


#ifndef __REVENG_MATH_BASE_HPP__
#define __REVENG_MATH_BASE_HPP__

#include <cmath>

namespace RevEng
{
    namespace Math
    {
        template<typename T>
        struct Epsilon
        {
            static T Value;
        };
        
        template<typename T>
        T Epsilon<T>::Value = static_cast<T>(0.00001);
        
        
        template<typename T>
        bool Equals(const T& Val1, const T& Val2)
        {
            return Val1 == Val2;
        }
        
        template<>
        inline bool Equals<float>(const float& Val1, const float& Val2)
        {
            return ::fabs(Val1 - Val2) < Epsilon<float>::Value;
        }
        
        template<>
        inline bool Equals<double>(const double& Val1, const double& Val2)
        {
            return ::fabs(Val1 - Val2) < Epsilon<double>::Value;
        }
    }
}

#endif  //__REVENG_MATH_BASE_HPP__
